<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-10-14 20:30:41
 * @LastEditTime: 2019-10-16 15:54:59
 * @LastEditors: Please set LastEditors
 -->
<template>
  <div>
    <div id="slider" class="mui-slider">
				<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
					<div class="mui-scroll">
						<a :class="['mui-control-item',item.id == 0 ? 'mui-active':'']" v-for="item in imgCategory" :key="item.id" @click="getImages(item.id)">
							{{item.title}}
						</a>
					</div>
				</div>
    </div>
    <ul class="photo-list">
      <router-link v-for="item in imgList" :key="item.id" :to="'/home/photoInfo/'+item.id" tag="li">
      <img v-lazy="item.img_url">
      <div class="info">
        <div class="info-title">{{item.title}}</div>
        <div class="info-content">{{item.zhaiyao}}</div>
      </div>
      </router-link>
    </ul>
  </div>
</template>
<script>
import mui from "../../lib/mui/js/mui.min.js";
export default {
 data(){
   return{
     imgCategory:[],
     imgList:[]
   }
 },
 mounted() {
  mui('.mui-scroll-wrapper').scroll({
	deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
});
},
created(){
  this.getImgCategory()
  this.getImages(0)
},
methods: {
  getImgCategory(){
    this.$http.get('api/getimgcategory').then(result=>{
      var res=result.body
      if(res.status===0){
        this.imgCategory=res.message
        this.imgCategory.unshift({id:0,title:'全部'})
      }
    })
  },
  getImages(id){
    this.$http.get('api/getimages/'+id).then(result=>{
      var res=result.body
      if(res.status===0){
        this.imgList=res.message
        console.log(this.imgList);
      }
    })
  }
},
 
}
</script>
<style lang="scss" scoped>
* {
  touch-action: pan-y;
}
.photo-list{
  padding: 0;
  margin: 0;
  list-style: none;
  li{
    background-color: #ccc;
    text-align: center;
    margin: 10px;
    position: relative;
    box-shadow: 1px 1px 6px #333333;
  }
  img{
    width: 100%;
    vertical-align: middle;
  }
  img[lazy=loading] {
  width: 40px;
  height: 300px;
  margin: auto;
}
  .info{
    position: absolute;   
    bottom: 0px;
    background-color: rgba(0, 0, 0, 0.4);
    color: white;
    text-align: left;
    .info-title{
      font-size: 13px;
      font-weight: bold;
    }
    .info-content{
      font-size: 12px;
    }
  }
}


</style>